import Vue from "vue";
import VueRouter from "vue-router";

import Layout from "@/layout";
import Pages from "./modules/pages"
import Effect from "./modules/effect"
import Component from "./modules/component"

Vue.use(VueRouter);

const routerPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
	return routerPush.call(this, location).catch(error=> error)
}


// 默认路由
const defaultRouter = [
	{
		path: '/',
		component: Layout,
		redirect: '/component'
	},
];

const roleRouter = [
    ...Pages,
    ...Effect,
    ...Component
];

const router = new VueRouter({
    routes: [
		...defaultRouter,
		...roleRouter
	]
});

export default router;